from django.db import models
from web.tagging.fields import TagField

class Idea(models.Model):
    title = models.CharField(maxlength=200)
    author = models.CharField(maxlength=200)
    tags = TagField()
    text = models.SlugField()
    change_date = models.DateTimeField(auto_now=True)
    pub_date = models.DateTimeField(auto_now_add=True)
    
    def __str__(self):
        return self.title
    
    def addComment(comment):
       self.comment_set.add(comment)

class Comment(models.Model):
    title = models.CharField(maxlength=200)
    text = models.TextField()
    pub_date = models.DateTimeField(auto_now_add=True)
    idea = models.ForeignKey(Idea)

    def __str__(self):
        return self.title